package com.walleipt.corgi.api.common;

import java.sql.SQLException;

import org.h2.tools.Server;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.walleipt.corgi.api.common.dao.mysql.SmartCommonDao;

public class H2Server {

	private final static Logger logger = LoggerFactory.getLogger(SmartCommonDao.class);
	
	private static Server server;
	
	public static void started() {
		try {
			logger.info("正在启动h2数据库...");
			server = Server.createWebServer().start(); // port 8082
			logger.info("h2数据库启动成功,port(8082) ...");
		} catch (SQLException e) {
			logger.info("启动h2数据库出错：" + e.toString());
			throw new RuntimeException(e);
		}
		
		H2ServerInitLoader.initLoadData() ;
	}

	

	public static void stoped() {
		server.shutdown();
		logger.info( "h2数据库已停止..." );
	}


}
